--计算2个角度之间的夹角
--	@夹角[0, 180]
--	@旋转方向(1 = 逆时针旋转, -1 = 顺时针旋转)
function ac.math_angle(r1, r2)
	local r = (r1 - r2) % 360
	if r >= 180 then
		return 360 - r, 1
	else
		return r, -1
	end
end

function ac.transfer_player(p, rectName, useIdx)
    local map = require 'maps.map'
    local jass = require 'jass.common'
    if p and p.hero then
		local idx = p.id
        local rect = map.rects[rectName]
        if not rect then
            print('未注册区域 ', rectName)
            return
        end
		if useIdx then
			rect = rect[idx]
		end
        local point = rect:get_point()
        local x, y = point:get()
        p.hero:setPoint(point)
        jass.PanCameraToTimed(x, y, 0.1)
    end
end

function ac.handle_shop_unit(u)
	u:add_ability(GameEnum.Ability.ABILITY_CHOOSE_HERO)
	u:add_ability(GameEnum.Ability.ABILITY_INVINCIBLE)
end

function ac.is_empty_or_nil(str)
    return not str or str == ''
end